import request from '@/utils/request'

// 注册接口
export const userRegisterService = (registerData)=>{
    var params = new URLSearchParams();
    for (let key in registerData) {
        params.append(key, registerData[key])
    }
    //添加完之后，params的格式自动给转为：username=xxx&password=xxx&repassword=xxx
    return request.post('/user/register', params);
}

// 登录接口
export const userLoginService = (registerData)=>{
    var params = new URLSearchParams();
    for (let key in registerData) {
        params.append(key, registerData[key])
    }
    console.log("传递的参数",params)
    return request.post('/user/login', params);
}

// 获取用户信息接口
export const getUserInfoService = ()=>{
    return request.get('/user/userInfo');
}

//获取用户个人信息接口
export const getUserPersonalInfoService = ()=>{
    return request.get('/user/person/info');
}

//获取用户投递职位信息
export const getUserJobInfoService = ()=>{
    return request.get('/user/person/JobInfo');
}

//展示所有个人用户
export const getAllUsersService = (data)=>{
    var params = new URLSearchParams();
    for (let key in data) {
        params.append(key, data[key])
    }
    return request.post('/user/allUsers', params);
}

//更新用户信息接口
export const updateUserInfoService = (updateData)=>{
    return request.put('/user/update', updateData);
}

//更新用户头像接口
export const updateUserAvatarService = (headImg)=>{
    return request.patch(`/user/headImg?headImg=${headImg}`);
}


//用户忘记密码接口
export const userForgetPasswordService = (phone)=>{
    return request.post(`/user/forgetPassword?phone=${phone}`)
}

//修改密码接口
export const userUpdatePasswordService = (code, mycode, username, phone, password)=>{
    return request.post(`/user/updatePassword?code=${code}&mycode=${mycode}&username=${username}&phone=${phone}&password=${password}`);
}

//用户引导页接口
export const userPersonGuideService = (userInfo)=>{
    return request.post('/user/person/guide', userInfo);
}

//企业引导页接口
export const userCompanyGuideService = (companyInfo)=>{
    return request.post('/user/company/guide', companyInfo);
}

//查看企业名称是否存在
export const CheckCompanyService = (companyName)=>{
    return request.post(`/user/checkCompanyName?companyName=${companyName}`);
}

////删除收藏的职位记录
export const removeCollectJobService = (jobId, companyId)=>{
    return request.post(`/user/removeCollectJob?jobId=${jobId}&companyId=${companyId}`);
}
// 删除投递简历记录
export const removePostJobService = (jobId, companyId)=>{
    return request.post(`/user/removePostJob?jobId=${jobId}&companyId=${companyId}`);
}
// 删除面试邀请记录
export const removeRecruitJobService = (jobId, companyId)=>{
    return request.post(`/user/removeRecruitJob?jobId=${jobId}&companyId=${companyId}`);
}

// 修改个人信息接口
export const updatePersonalInfoService = (personalInfo)=>{
    return request.post('/user/person/updateInfo', personalInfo);
}

//修改公司信息接口
export const updateCompanyInfoService = (companyInfo)=>{
    return request.post('/user/company/updateInfo', companyInfo);
}

//升级用户
export const updateUserService = (userId) =>{
    return request.post(`/user/upgrade?userId=${userId}`)
}

//获取公司用户信息
export const getCompanyPersonalInfoService = () =>{
    return request.get(`/user/company/userInfo`)
}

//更新用户的投递岗位的消息列表
export const updatePersonMessageService = (jobId, companyId, resumeId, approve)=>{
    return request.post(`/user/updatePersonMessage?jobId=${jobId}&companyId=${companyId}&resumeId=${resumeId}&approve=${approve}`)
}

//获取简历信息通过id
export const getResumeByIdService = (userId)=>{
    return request.post(`/user/getResumeId?userId=${userId}`)
}





